package routers

import (
	"github.com/kataras/iris/core/router"
	"github.com/kataras/iris"
	"irisx/servers/fg"
)

func WebSocketRouter(api router.Party){

	// 访问index,html页面
	api.Get("/", func(ctx iris.Context) {
		ctx.View("ws.html",false)
	})

	setupWebsocket(api)
}

func setupWebsocket(api router.Party) {

	fgws := fg.NewFg()

	api.Get(fgws.Name, fgws.Handler)

	api.Any("/iris-ws.js", func(ctx iris.Context) {
		ctx.Write(fgws.Ws.ClientSource)
	})

}
